import http_tls
import flowtool
import utility
import sites_plugin

test_base_floder_path = '/home/dev/Desktop/capreader_trace'
output_file_path = "/home/dev/Desktop/missed_http_tls_result.txt"

"""

http_tls.py test cases

"""
pkt_log_file_path = test_base_floder_path + "/trace.pcap.pkt.log"
pkt_log_file_folder = test_base_floder_path

def test_missed_http_tls():
    try:
        ht = http_tls.HttpTls()
        ht.missed_http_tls(pkt_log_file_path)
    except:
        print "Failed http_tls:\tmissed_http_tls()"
        raise
test_missed_http_tls()

def test_missed_http_tls_folder():
    try:
        ht = http_tls.HttpTls()
        ht.missed_http_tls_folder(pkt_log_file_folder, output_file_path)
    except:
        print "Failed http_tls:\tmissed_http_tls_flder()"
        raise
test_missed_http_tls_folder()


"""

sites_plugin.py test cases

"""
guid_def_sample = '#define GUID_CPXINTAC    "CPXINTAC"    /* CPX Interactive Ads/Analytics site */'
rule_sample = '{ "HTTP", "Host", "*.daum-img.net", GUID_DAUM, 0 },'

def test_valid_guid_definition():
    try:
        sites = sites_plugin.Sites_plugin()
        if not (sites.valid_guid_definition(guid_def_sample)):
            print "Failed sites_plugin:\tvalid_guid_definition()"
    except:
        print "Failed sites_plugin:\tvalid_guid_definition()"
        raise
test_valid_guid_definition()

def test_valid_rule():
    try:
        sites = sites_plugin.Sites_plugin()
        if not (sites.valid_rules(rule_sample)):
            print "Failed sites_plugin:\ttest_valid_rule()"
    except:
        print "Failed sites_plugin:\ttest_valid_rule()"
        raise
test_valid_rule()


"""
flowtool.py test cases
"""
pcap_path = test_base_floder_path + "/trace.pcap"
pcap_folder = test_base_floder_path

def test_run_flowtool():
    try:
        ft = flowtool.Flowtool()
        ft.run_flowtool(pcap_path)
    except:
        print "Failed flowtool: run_flowtool()"
        raise
test_run_flowtool()

def test_run_flowtool_folder():
    try:
        ft = flowtool.Flowtool()
        ft.run_flowtool_folder(pcap_folder)
    except:
        print "Failed flowtool: run_flowtool_folder()"
        raise
test_run_flowtool_folder()